package com.jialiang.yojcodesandbox.service.factory;

import com.jialiang.yojcodesandbox.enums.QuestionSubmitLanguageEnum;
import com.jialiang.yojcodesandbox.service.CodeSandbox;
import com.jialiang.yojcodesandbox.service.impl.cpp.CppNativeCodeSandbox;
import com.jialiang.yojcodesandbox.service.impl.java.JavaNativeCodeSandbox;
import org.apache.commons.lang3.ObjectUtils;

public class CodeSandboxFactory {
    public static CodeSandbox getInstance(QuestionSubmitLanguageEnum language) {
        if(ObjectUtils.isEmpty(language)){
            throw new RuntimeException("编程语言为空");
        }
        switch (language) {
            case JAVA:
                return new JavaNativeCodeSandbox();
            case CPP:
                return new CppNativeCodeSandbox();
            default:
                throw new RuntimeException("暂不支持");
        }
    }
}
